#ifndef __PCF8591_H_
#define __PCF8591_H_

#include "sys.h"

#define PCF8591_DEBUG 0

#define PCF8591_ADDR (0x48)
#define PCF8591_OUTPUT (0x40)
#define PCF8591_AUTO_INCREASE (0x04)
#define PCF8591_ADC_CHANNEL_0 (0x00)
#define PCF8591_ADC_CHANNEL_1 (0x01)
#define PCF8591_ADC_CHANNEL_2 (0x02)
#define PCF8591_ADC_CHANNEL_3 (0x03)

typedef struct
{
    uint8_t adc_channel_0;
    uint8_t adc_channel_1;
    uint8_t adc_channel_2;
    uint8_t adc_channel_3;
} pcf8591_t;

void pcf8591_init(void);
pcf8591_t *pcf8591_adc_struct_panel(void);
uint8_t pcf8591_read_adc(uint8_t channel);
void pcf8591_set_dac(uint8_t input_dac);

void pcf8591_adc_demo();
void pcf8591_dac_demo();

#endif
